import * as THREE from "three"
import configConst from "../constant/config.const"
import r from "../math/69626"
import { LineEndpointMaterial } from "../module/LinesModule"
export default class LineEndpoint extends THREE.Mesh<THREE.PlaneGeometry, LineEndpointMaterial> {
  part: string
  selectedSize: number
  defaultSize: number
  currentSize: number
  constructor(e, t, i = configConst.lineConfig.endpointSelected, n = configConst.lineConfig.endpointDefault) {
    super(e, t)
    this.selectedSize = i
    this.defaultSize = n
    this.currentSize = configConst.lineConfig.endpointDefault
    this.currentSize = this.defaultSize
    this.scale.set(configConst.lineMinScale, configConst.lineMinScale, configConst.lineMinScale)
  }
  dispose() {
    this.material.dispose()
    this.geometry.dispose()
  }
  billboardScale(e, t, i) {
    const n = r.mY(t, e, this.position, i, 0.5),
      s = Math.max(Math.min((1 / n) * this.currentSize, configConst.lineMaxScale), configConst.lineMinScale)
    this.scale.set(s, s, s)
  }
  updateSelected(e) {
    this.currentSize = e ? this.selectedSize : this.defaultSize
  }
}
